
#include <iostream>
using namespace std;
class Person
{
public:
    Person();
    virtual ~Person();
    virtual void work() = 0;
};

Person::Person()
{
    cout << "Person()" << endl;
}

Person::~Person()
{
    cout << "~Person()" << endl;
}

void Person::work()
{
    cout << "Person::work()" << endl;
}

class Student : public Person
{
public:
    Student();
    ~Student();
    virtual void work();
};

Student::Student()
{
    cout << "Student()" << endl;
}

Student::~Student()
{
    cout << "~Student()" << endl;
}

void Student::work()
{
    cout << "Student::work()" << endl;
}

class Teacher : public Person
{
public:
    Teacher();
    ~Teacher();
    virtual void work();
};

Teacher::Teacher()
{
    cout << "Teacher()" << endl;
}

Teacher::~Teacher()
{
    cout << "~Teacher()" << endl;
}

void Teacher::work()
{
    cout << "Teacher::work()" << endl;
}


int main()
{
    Person *per = new Person;
    Person *stu = new Student;
    Person *tea = new Teacher;
    per->work();
    stu->work();
    tea->work();
    delete per;
    per = nullptr;
    delete stu;
    stu = nullptr;
    delete tea;
    tea = nullptr;
    return 0;
}